package com.xxx.state;

import java.util.concurrent.locks.LockSupport;

/**
 * @version v1.0
 * @Description:
 * @Author zhanzhongxin
 * @Date 2021/7/30 15:14
 * @Copyright 博为峰
 */
public class WaitDemo02 {

    public static Object obj = new Object();

    public static void main(String[] args) {
        final Thread thread = new Thread(new Runnable() {//Thread-0
            @Override
            public void run() {
                System.out.println(Thread.currentThread().getName() + "-A");
                LockSupport.park();//阻塞
                System.out.println(Thread.currentThread().getName() + "-B");
            }
        });
        thread.start();
        try {
            Thread.sleep(1000);//不释放锁
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        synchronized (obj) {
            System.out.println(Thread.currentThread().getName() + "-C");
            LockSupport.unpark(thread);
        }
    }
}
